﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicUniversityBiz;

namespace LogicUniversity.Employee
{
    public partial class ViewReqDetail : System.Web.UI.Page
    {
        private CoreHeadFascade fs = new CoreHeadFascade();
        protected void Page_PreInit(Object sender, EventArgs e)
        {
            //if (Session["Role"] as string != "Employee" || Session["Role"] as string != "Representative")
            //{
            //    
            //}
            if (Session["Role"] as string != "Employee")
            {
                if (Session["Role"] as string == "Representative")
                {
                    this.MasterPageFile = "~/Representative/RepMaster.Master";
                }
                else
                {
                    Response.Redirect("~/Login.aspx");
                }
            }

        }
   
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                fillData();
            }
        }

        private void fillData()
        {
            int reqID = Convert.ToInt32(Request.QueryString["reqid"] as string);
            Requisition req = fs.getRequision(reqID);

            ReqID.Text = reqID.ToString();
            reqDate.Text = req.Requested_Date.ToShortDateString();
            status.Text = req.Status;

            if (req.Reason == null)
            {
                reason.Visible = false;
            }
            else
            {
                RejectReason.Text = req.Reason;
            }

            List<Requisition_Detail> reqDetail = fs.getReqDetail(reqID);
            ItemView.DataSource = reqDetail;
            ItemView.DataBind();
        }
    }
}